﻿#region using

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

#endregion

namespace JupiterLibrary.UI
{
    public class GUI
    {
        public struct GUIDCursor
        {
            public Point Position;
        }

        public struct Preferences
        {
            public Color WindowBackgroundColor;
            public Color WindowTitleColor;
        }

        public Windows Windows { get; private set; }

        public Texture_2D GUITexture { get; private set; }

        public GUIDCursor Cursor;

        public SpriteBatch spriteBatch;

        public Preferences Prefs;

        public GUI()
        {
            bool methodLog = Jupiter.Log.BeginMethod();

            Windows = new Windows();

            spriteBatch = new SpriteBatch(Jupiter.Video.GraphicsDevice);

            SetDefaultPrefs();

            if (methodLog) Jupiter.Log.EndMethod();
        }

        public void LoadContent()
        {
            // We need to load our GUI basic texture

            GUITexture = Jupiter.Video.Textures.CreateAndAdd(@"UI\UI", true);

            GUITexture.CreateClips(false, TextureClipModes.Pixel0IsBackground, true, true);

        }

        void SetDefaultPrefs()
        {
            Prefs.WindowBackgroundColor = new Color(0.5f, 0.5f, 1.0f);
            Prefs.WindowTitleColor = new Color(0.2f, 0.2f, 0.7f);
        }

        public void Update()
        {
            Windows.Update();

            // The Cursor

            Cursor.Position = Jupiter.Input.MousePosition;
        }

        public void Draw()
        {
            Windows.Draw();

            // Dibujo el Cursor

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);

            GUITexture.Clips[0].Draw(Cursor.Position, spriteBatch);

            spriteBatch.End();
        }
 }
}
